﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MapCop.Rules
{
    class LabelFunctoidsMapRule : IMapRule
    {
        #region IMapRule Members

        public List<MapError> AnalyzeMap(Map map)
        {
            List<MapError> errList = new List<MapError>();

            foreach (MapPage loopPage in map.Pages)
            {
                foreach (MapPageFunctoid loopFunc in loopPage.Functoids)
                {
                    if (loopFunc.Label.Length.Equals(0) ||
                        loopFunc.Label.Trim() == loopFunc.Name.Trim())
                    {
                        MapError newError = new MapError();
                        newError.Page = loopPage;
                        newError.Severity = ErrorSeverity.Medium;
                        newError.Title = "Label all functoids";
                        newError.Description = "All functoids should have " +
                            "their Label property set to make clear their purpose. " + 
                            "This cannot be circumvented by setting the label to the " + 
                            "name of the functoid.";

                        errList.Add(newError);
                    }
                }
            }

            return errList;
        }

        #endregion
    }
}
